package com.c.ctgproject.base

import com.c.ctgproject.wiget.dialog.LoadingDialog

/**
 *描述:MvpActivity基类
 *作者:LiBW
 *创建日期: 2020/7/1
 */
abstract class BaseMvpActivity<T : BasePresenter<*>> : BaseActivity(), BaseView {
    //仿苹果小菊花
    private val loadingDialog: LoadingDialog by lazy { LoadingDialog(this) }

    var mPresenter: T? = null



    /**当出现错误统一处理*/
    override fun onError(error: String) {
        if (loadingDialog.isShowing) loadingDialog.hide()
    }


    /**展示loading小菊花*/
    override fun showLoading() {
        loadingDialog.show()
    }

    /**隐藏loading小菊花*/
    override fun hideLoading() {
        if (loadingDialog.isShowing) loadingDialog.hide()
    }

    //解绑 p层和v层
    override fun onDestroy() {
        super.onDestroy()
        mPresenter?.mView=null
        mPresenter = null
        //释放资源
        loadingDialog.dismiss()
    }
}